﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
using SiyinPractice.Infrastructure.EntityFramework;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class MySqlServiceCollectionExtension
    {
        public static IServiceCollection AddMySqlServer(this IServiceCollection services, string connectiongString)
        {
            var serverVersion = new MariaDbServerVersion(new Version(8, 2, 0));
            services.AddDbContext<DbContext, SiyinPracticeMySqlDbContext>(options =>
                                             options
                                             .UseMySql(connectiongString, serverVersion)
                                             );

            return services;
        }
    }
}